LibGDX Cross-Platform Development Blueprints by Unknown

LibGDX Cross-Platform Development Blueprints by Unknown

Author:Unknown
Language: eng
Format: epub
Publisher: Packt Publishing


Then, edit the corresponding line in GameScreen:

Gdx.input.setInputProcessor(new InputManager(camera)); // enable InputManager to receive input events

We will override the onTouchUp() and onTouchDown()callback methods in InputManager. The onTouchDown() method is called when the user touches the screen. The onTouchUp() method is called when the user lifts their finger from the screen:

@Override public boolean touchDown(int screenX, int screenY, int pointer, int button) { temp.set(screenX,screenY, 0); //get the touch co-ordinates with respect to the camera's viewport camera.unproject(temp); float touchX = temp.x; float touchY = temp.y; if(isLeftPaddleTouched(touchX,touchY)){ GameManager.bob.setLeftPaddleTouched(true); } else if(isRightPaddleTouched(touchX,touchY)){ GameManager.bob.setRightPaddleTouched(true); } return false; } @Override public boolean touchUp(int screenX, int screenY, int pointer, int button) { temp.set(screenX,screenY, 0); //get the touch co-ordinates with respect to the camera's viewport camera.unproject(temp); float touchX = temp.x; float touchY = temp.y; if(isLeftPaddleTouched(touchX,touchY)){ GameManager.bob.setLeftPaddleTouched(false); } else if(isRightPaddleTouched(touchX,touchY)){ GameManager.bob.setRightPaddleTouched(false); } return false; }



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.